<script>
import BookshelfApi from '../../api/bookshelf';
export default {
    props: ["bookId"],
    data() {
        return {
            avgRanking: 0
        }
    },
    methods: {
        async getAvgRanking() {
            try {
                const api = new BookshelfApi();
                let res = await api.avgRankingByBookId(this.bookId);
                let avg = res.data.average ? res.data.average : 0;
                this.avgRanking = avg.toFixed(2);
            } catch (err) {
                console.error(err);
                this.$myMessageBox("应用服务器访问错误！");
            }
        }
    },
    mounted() {
        this.getAvgRanking();
    },
}
</script>

<template>
    <div>综合评分：{{ avgRanking }}</div>
</template>

<style scoped>
div {
    margin-top: 16px;
}
</style>